import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'

const routes: Array<RouteRecordRaw> = [
  {
    path: '/login',
    component: () => import('../pages/login.vue')
  },
  {
    path: "/index",
    component: () => import("../pages/index.vue"),
    children: [
      {
        path: "/home",
        component: () => import("../views/home/index.vue")
      },
      {   
        path: "/role",
        component: () => import("../views/role/index.vue"),
        meta: {
          title: "角色管理"
        }
      },
      {
        path: "/menu",
        component: () => import("../views/menu/index.vue"),
        meta: {
          title: "菜单管理"
        }
      },
      {
        path: "/admin",
        component: () => import("../views/admin/index.vue"),
        meta: {
          title: "管理员管理"
        }
      },
      // 重定向
      {
        path: "",
        redirect: "/home"
      },
    ]
  },
  {
    path: "/404",
    component: () => import("../pages/404.vue")
  },
  {
    path: "/:pathMatch(.*)",
    redirect: "/404"
  },
  {
    path: "/",
    redirect: "/login"
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router
